﻿@{
    ViewBag.Title = "Home Page";
}
<script type="text/javascript">
    function init(data) {
        //empty div map
        $("#map").empty();

        map = new OpenLayers.Map("map");
        var mapnik = new OpenLayers.Layer.OSM();
        var fromProjection = new OpenLayers.Projection("EPSG:4326");   // Transform from WGS 1984
        var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
        var position = new OpenLayers.LonLat(108.202622, 16.051794).transform(fromProjection, toProjection);
        var zoom = 13;

        map.addLayer(mapnik);

        if (data) {
            var markers = new OpenLayers.Layer.Markers("Markers");
            map.addLayer(markers);
            $.each(data, function (i, item) {
                var position1 = new OpenLayers.LonLat(item.Toadoy, item.Toadox).transform(fromProjection, toProjection);
                markers.addMarker(new OpenLayers.Marker(position1));
            });

        }
        map.setCenter(position, zoom);
    }

    $(document).ready(function () {
        init();
    });
</script>
<div class="post">
    <a name="TemplateInfo"></a>    
    <div id="map" style="width: 100%; height: 500px; padding: 10px">
    </div>
</div>

